/* 类装饰器:定义类装饰器函数*/ 
function extendsAttr(attr,value){
    return function(target){
        /* target代表类本身 */
        target[attr]=value;
    }
}

/* 调用类装饰器函数: 通过装饰器给类动态扩展成员属性*/
@extendsAttr('country','中国')
class Person{
    public name;
    public age;
    constructor(options){
       this.name=options.name;
       this.age=options.age; 
    }
    sayHi(){
        console.log('hello world');
    }
}

const p1=new Person({name:'zs',age:30});
console.log(p1,Person.country);


